﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;

namespace TinyERPApp
{
    public class ApplicationInfo
    {
        public static string VersionNumber { get; set; }
        public static string Description { get; set; }
        public static string LongDescription { get; set; }
        public static IList<DeveloperInfo> Developers { get; set; }
        public static void LoadInfo()
        {
            XmlDocument xmlDocument = new XmlDocument();
            xmlDocument.Load("Version/Version.xml");
            Description = xmlDocument.SelectSingleNode("version/description").InnerText;
            LongDescription = xmlDocument.SelectSingleNode("version/long-description").InnerText;
            VersionNumber = xmlDocument.SelectSingleNode("version/version-number").InnerText;
            Developers = new List<DeveloperInfo>();
            XmlNodeList xmlDeveloperNodeList = xmlDocument.SelectNodes("version/team/developer");
            foreach (XmlNode xmlDeveloperNode in xmlDeveloperNodeList)
            {
                DeveloperInfo developer = new DeveloperInfo();
                developer.Name = xmlDeveloperNode.Attributes["name"]!=null?xmlDeveloperNode.Attributes["name"].Value:"";
                developer.Email = xmlDeveloperNode.Attributes["email"] != null ? xmlDeveloperNode.Attributes["email"].Value : "";
                developer.HomePage = xmlDeveloperNode.Attributes["homepage"] != null ? xmlDeveloperNode.Attributes["homepage"].Value : "";

                Developers.Add(developer);
            }
        }
    }
    public class DeveloperInfo
    {
        public string Name { get; set; }
        public string Email { get; set; }
        public string HomePage { get; set; }
    }
}
